bitkeeper revision 1.753 (403e2103aB5fs34t3drynDYnNdeFiw)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 26 Feb 2004 16:38:27 +0000 (16:38 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 26 Feb 2004 16:38:27 +0000 (16:38 +0000)
kernel.c, process.c:
  Fix bug in idle-task switching.

xen/arch/i386/process.c
xen/common/kernel.c

index 62725ea84d38a7889bdd5ac7d2a1da74531881f1..9adfb5ff40217a4d272f27e6e163fc0ad381943a 100644 (file)
@@ -235,33 +235,49 @@ void switch_to(struct task_struct *prev_p, struct task_struct *next_p)
     __cli();
 
     /* Switch guest general-register state. */
-    memcpy(&prev_p->shared_info->execution_context, 
-           stack_ec, 
-           sizeof(*stack_ec));
-    memcpy(stack_ec,
-           &next_p->shared_info->execution_context,
-           sizeof(*stack_ec));
-
-    /*
-     * This is sufficient! If the descriptor DPL differs from CS RPL
-     * then we'll #GP. If DS, ES, FS, GS are DPL 0 then they'll be
-     * cleared automatically. If SS RPL or DPL differs from CS RPL
-     * then we'll #GP.
-     */
-    if ( (stack_ec->cs & 3) == 0 )
-        stack_ec->cs = FLAT_RING1_CS;
-    if ( (stack_ec->ss & 3) == 0 )
-        stack_ec->ss = FLAT_RING1_DS;
-
-    unlazy_fpu(prev_p);
-
-    /* Switch the fast-trap handler. */
-    CLEAR_FAST_TRAP(&prev_p->thread);
-    SET_FAST_TRAP(&next_p->thread);
+    if ( !is_idle_task(prev_p) )
+    {
+        memcpy(&prev_p->shared_info->execution_context, 
+               stack_ec, 
+               sizeof(*stack_ec));
+        unlazy_fpu(prev_p);
+        CLEAR_FAST_TRAP(&prev_p->thread);
+    }
 
-    /* Switch the guest OS ring-1 stack. */
-    tss->esp1 = next->esp1;
-    tss->ss1  = next->ss1;
+    if ( !is_idle_task(next_p) )
+    {
+        memcpy(stack_ec,
+               &next_p->shared_info->execution_context,
+               sizeof(*stack_ec));
+
+        /*
+         * This is sufficient! If the descriptor DPL differs from CS RPL then 
+         * we'll #GP. If DS, ES, FS, GS are DPL 0 then they'll be cleared 
+         * automatically. If SS RPL or DPL differs from CS RPL then we'll #GP.
+         */
+        if ( (stack_ec->cs & 3) == 0 )
+            stack_ec->cs = FLAT_RING1_CS;
+        if ( (stack_ec->ss & 3) == 0 )
+            stack_ec->ss = FLAT_RING1_DS;
+
+        SET_FAST_TRAP(&next_p->thread);
+
+        /* Switch the guest OS ring-1 stack. */
+        tss->esp1 = next->esp1;
+        tss->ss1  = next->ss1;
+
+        /* Maybe switch the debug registers. */
+        if ( next->debugreg[7] )
+        {
+            loaddebug(next, 0);
+            loaddebug(next, 1);
+            loaddebug(next, 2);
+            loaddebug(next, 3);
+            /* no 4 and 5 */
+            loaddebug(next, 6);
+            loaddebug(next, 7);
+        }
+    }
 
     /* Switch page tables.  */
     write_cr3_counted(pagetable_val(next_p->mm.pagetable));
@@ -272,18 +288,6 @@ void switch_to(struct task_struct *prev_p, struct task_struct *next_p)
     __asm__ __volatile__ ("lgdt %0" : "=m" (*next_p->mm.gdt));
     load_LDT(next_p);
 
-    /* Maybe switch the debug registers. */
-    if ( next->debugreg[7] )
-    {
-        loaddebug(next, 0);
-        loaddebug(next, 1);
-        loaddebug(next, 2);
-        loaddebug(next, 3);
-        /* no 4 and 5 */
-        loaddebug(next, 6);
-        loaddebug(next, 7);
-    }
-
     __sti();
 }
 
index 3f1d0fd24c4c871fd33f221387191a2af2587ca4..9db60eca822247699a9d0b32ac07600579674367 100644 (file)
@@ -224,11 +224,6 @@ void cmain(unsigned long magic, multiboot_info_t *mbi)
 
     init_page_allocator(__pa(&_end), MAX_MONITOR_ADDRESS);
  
-    /* These things will get done by do_createdomain() for all other tasks. */
-    current->shared_info = (void *)get_free_page(GFP_KERNEL);
-    memset(current->shared_info, 0, sizeof(shared_info_t));
-    set_fs(USER_DS);
-
     /* Initialise the slab allocator. */
     kmem_cache_init();
     kmem_cache_sizes_init(max_page);